10 !******************************************************************************** 20 ! 30 ! PROGRAM NAME: RS232ex2.txt 40 ! 50 ! PROGRAM DESCRIPTION: In this example, query commands are used to read 60 ! data from the signal generator. 70 ! 80 ! Start Agilent BASIC, type in the following code and then RUN the program. 90 ! 100 !******************************************************************************** 110 ! 120 INTEGER Num 130 DIM Str$[200],Str1$[20] 140 CONTROL 9,0;1 ! Reset the RS-232 interface 150 CONTROL 9,3;9600 ! Set the baud rate to match signal generator rate 160 STATUS 9,4;Stat ! Read the value of register 4 170 Num=BINAND(Stat,7) ! Get the AND value 180 CONTROL 9,4;Num ! Set the parity to NONE 190 OUTPUT 9;"*IDN?" ! Query the sig gen ID 200 ENTER 9;Str$ ! Read the ID 210 WAIT 2 ! Wait 2 seconds 220 PRINT "ID =",Str$ ! Print ID to the screen 230 OUTPUT 9;"POW:AMPL -5 dbm" ! Set the the power level to -5 dbm 240 OUTPUT 9;"POW?" ! Query the power level of the sig gen 250 ENTER 9;Str1$ ! Read the queried value 260 PRINT "Power = ",Str1$ ! Print the power level to the screen 270 END ! End the program